<%@page contentType="text/html; charset=UTF-8"%>
<%@include file="/teleweb/common/global.jsp" %>
<html>
	<head>
	<script type="text/javascript" src="dwr/engine.js"></script>
	<script type="text/javascript" src="dwr/util.js"></script>
	<script type="text/javascript" src="dwr/interface/excel.js"></script>
		<title>用户注册</title>
		
	<script>
		
		window.returnValue="abc";
	
		function importExcel() {
			process();
			document.getElementById("random").value = document.getElementById("randomfolder").value;
			if(document.getElementById("uploads").innerHTML == null || document.getElementById("uploads").innerHTML == "" || document.getElementById("uploads").innerHTML == "<UL></UL>") {
				alert("还没有导入Excel数据表。");
				return false;
			}
			DataImport.submit();
		}
		
		function process() {
			excel.getSessionValueByName(callBackFortestMethod);
			setTimeout("process()", 100);//每0.1毫秒钟刷新一次
		}
		function test1() {
			excel.returnString(callBackFortestMethod1);
		}
		function test2() {
			excel.returnList(callBackFortestMethod2);
		}
		function test3() {
			excel.returnMap(callBackFortestMethod3);
		}
		
		function callBackFortestMethod(data){
			var pro1;
			var pro2;
			for(var i=0; i<data.length; i++) {
				
			}
			for(var property in data){ 
				if(data["<%=Constant.EXCEL_IMPORT_NUM%>"] != null) {
					document.getElementById("value1").innerHTML = data["<%=Constant.EXCEL_IMPORT_NUM%>"];
				}
				if(data["<%=Constant.EXCEL_IMPORT_SUM%>"] != null) {
					document.getElementById("value2").innerHTML = data["<%=Constant.EXCEL_IMPORT_SUM%>"];
				}
			}
		}
		
		function callBackFortestMethod1(data){
			alert("the return value is " + data);
		}
		
		function callBackFortestMethod2(data){
			for(var i=0; i<data.length; i++) {
				alert(data[i]);
			}
		}
		
		function callBackFortestMethod3(data){
       		//其中date接收方法的返回值
			//对于JavaBean返回值，有两种方式处理
            //不知道属性名称时，使用如下方法
            for(var prop in data) {
				alert("Key=" + prop + "; Value=" + data[prop]);
			}
			for(var property in data){ 
				alert("property:"+property);
                alert(property+":"+data[property]);
			}
			//知道属性名称时，使用如下方法
			for(var i=0;i<data.length;i++){
 				alert(data.key1);
 				alert(data.key2);
			}
		}
			
		
	</script>
		
	</head>
	<base target="_self">
	<body>
		<center>
		<h3>请输入注册信息</h3><br/>
		<a href="exp-excel?className=WorkNews">Export Excel</a><br/><br/>
		<a href="imp-excel?className=WorkNews&excelPath=WORK_NEWS.xls">Import Excel</a><br/><br/>
		<form name="DataImport" action="imp-excel?className=WorkNews" method="post">
            <input type="hidden" name="random" id="random">
        </form>
            <input type="hidden" id="attachnum" name="attachnum" value="1">
            <input type="hidden" name="allowType" id="allowtype" value="xls">
		<upload:load></upload:load>
		<button onclick="test1()">-保1存-</button><button onclick="test2()">-保2存-</button><button onclick="test3()">-保3存-</button>
		
		<button id="saveBnt" disabled onclick="importExcel()">-导入数据-</button>
		
		<span id="value1">0</span>&nbsp;/&nbsp;<span id="value2">0</span>
		
		<input type="hidden" id="resetBnt">
		
		</center>
	</body>
</html>